//
//  UIImageView+Extension.swift
//  SinaImiate
//
//  Created by xiaoming on 16/7/5.
//  Copyright © 2016年 GoodJob. All rights reserved.
//

import Foundation


extension UIImageView {
    
    ///隔离SDWebImage 设置图像函数
    
    func cz_setImage(urlString: String?, placeholderImage: UIImage?, isAvatar: Bool = false) {
        
        guard let urlString = urlString,
            url = URL(string: urlString)
            else {
                
                image = placeholderImage
                
                return
        }
        
        sd_setImage(with: url, placeholderImage: placeholderImage, options: [], progress: nil) {[weak self] (image, _, _, _) in
            if isAvatar {
                self?.image = image?.cz_avatarImage(size: self?.bounds.size)
            }
        }
    }
    
}
